import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import '@/ui.scss'
import '@/style/index.scss'
import {Local,VueLocal} from "@/plugins/local";
import '@/fonts/css/fa-svg-with-js.css'
import '@/fonts/js/fontawesome-all.js'
import {Route} from "vue-router";
import VueImg from 'v-img';
import '@/style/libs/devices.min.css';

Vue.config.productionTip = false;

Vue.use(ElementUI);
Vue.use(VueLocal);
Vue.use(VueImg);


router.beforeEach((to, from, next) => {


    if(to.name !== 'login') {
        if(Local.HasSession()) {
            next()
        }else{
            next('/login')
        }
    }
    next()
});

router.afterEach((to: Route, from: Route) => {
    console.log("emit")
    Local.$emit('onRouteChanged', to, from)
});


new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app');
